home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / do-eve1r / module2.bas < prev    next >
Encoding:
BASIC Source File  |  1999-07-13  |  1.7 KB  |  70 lines

  1. Attribute VB_Name = "Module2"
  2. Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
  3.  
  4.  
  5. Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
  6.  
  7.  
  8. Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
  9.     (LpVersionInformation As OSVERSIONINFO) As Long
  10.     Public Const VK_MENU = &H12
  11.     Public Const KEYEVENTF_KEYUP = &H2
  12.  
  13.  
  14. Type OSVERSIONINFO
  15.     dwOSVersionInfoSize As Long
  16.     dwMajorVersion As Long
  17.     dwMinorVersion As Long
  18.     dwBuildNumber As Long
  19.     dwPlatformId As Long
  20.     szCSDVersion As String * 128 ' Maintenance string For PSS usage
  21.     End Type
  22.     
  23.  
  24. Public Sub GetWindowSnapShot(Mode As Long, ThisImage As PictureBox)
  25.  
  26.     
  27.     ' mode = 0 -> Screen snapshot
  28.     ' mode = 1 -> Window snapshot
  29.     
  30.     Dim altscan%, NT As Boolean, nmode As Long
  31.     
  32.     NT = IsNT
  33.  
  34.  
  35.     If Not NT Then
  36.         If Mode = 0& Then Mode = 1& Else Mode = 0&
  37.     End If
  38.  
  39.     
  40.  
  41.  
  42.     If NT And Mode = 0 Then
  43.         keybd_event vbKeySnapshot, 0&, 0&, 0&
  44.     Else
  45.         altscan = MapVirtualKey(VK_MENU, 0)
  46.         keybd_event VK_MENU, altscan, 0, 0
  47.  
  48.  
  49.         DoEvents
  50.             keybd_event vbKeySnapshot, Mode, 0&, 0&
  51.         End If
  52.  
  53.  
  54.  
  55.         DoEvents
  56.             ThisImage = Clipboard.GetData(vbCFBitmap)
  57.             keybd_event VK_MENU, altscan, KEYEVENTF_KEYUP, 0
  58.         End Sub
  59.  
  60.  
  61.  
  62. Public Function IsNT() As Boolean
  63.  
  64.     Dim verinfo As OSVERSIONINFO
  65.     verinfo.dwOSVersionInfoSize = Len(verinfo)
  66.     If (GetVersionEx(verinfo)) = 0 Then Exit Function
  67.     If verinfo.dwPlatformId = 2 Then IsNT = True
  68. End Function
  69.  
  70.